<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>回车报账管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
		$(".close,.closeBtn").click(function(){
				$("#formDispach").addClass("hide");
			    $("#maskY").addClass("hide");
	        	$("#listData").html("");
	        });
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        };
       /**
        *将运单的状态更改为审核中
        */
        function selectCostWaybillid(id,state,outCarmoney,obj){
        var avalue=obj.val();
            if(state==4 || state=="4" || state==5 || state=="5"){
		        $("#listData").html("");
		        avalue=obj.val("审核中");
		        $.ajax({
                url:"${ctx}/tb_enter_reimbursement/tbEnterReimbursement/changeStatu",
		        type:"post",
		        data:{
		            id:id,
		            updatastatu:5,
		            outCarmoney:outCarmoney
		            },
				dataType:"json",
		        success:function(data){
		        if(data != null && data != ''){        
	            var listStr ="<ul class='tanUl'>"+
				        			"<li><h4>现&nbsp&nbsp&nbsp金&nbsp&nbsp&nbsp加&nbsp&nbsp&nbsp油："+data.fuel_price+"</h4></li>"+
				        			"<li><h4>罐&nbsp&nbsp&nbsp车&nbsp&nbsp&nbsp加&nbsp&nbsp&nbsp油："+data.fuel_weight+"kg</h4></li>"+
				        			"<li><h4>过&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp路&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.roadtoll+"&nbsp&nbsp&nbspm³</h4></li>"+
				        			"<li><h4>住&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp宿&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.getaccommodation+"&nbsp&nbsp&nbspm³</h4></li>"+
				        			"<li><h4>配&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp件&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.accessoryfee+"<h4></li>"+
				        			"<li><h4>维&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp修&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.maintenance_cost+"</h4></li>"+
				        			"<li><h4>保&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp养&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.upkeep_cost+"</h4></li>"+
				        			"<li><h4>协&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp调&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.concert_cost+"</h4></li>"+
				        			"<li><h4>其&nbsp&nbsp&nbsp它&nbsp&nbsp&nbsp费&nbsp&nbsp&nbsp用："+data.other_cost+"</h4></li>"+
				        			"<li><h4>出&nbsp&nbsp&nbsp车&nbsp&nbsp&nbsp领&nbsp&nbsp&nbsp款："+data.outCarmoney+"</h4></li>"+
				        			"<li><h4>剩&nbsp&nbsp&nbsp余&nbsp&nbsp&nbsp费&nbsp&nbsp&nbsp用："+data.return_cost+"</h4></li>"+
				        			"</ul>";
				 var buttontype="<input type='button' onclick='addenterreimbursement("+JSON.stringify(data)+")' value='报账' class='btn btn-default pull-left' data-dismiss='modal'/>";
				 $("#listData").append(listStr);
				 $(".modal-footer").append(buttontype);	           
		        }		        
		       } 
            });
             $(".tan").removeClass("hide");
			}else if(state==6 || state=="6"){
			     $("#listData").html("");
			     avalue=obj.val("查看已报账");
			     $.ajax({
                 url:"${ctx}/tb_enter_reimbursement/tbEnterReimbursement/showtbEnterReimbursement",
		         type:"post",
		         data:{
		             id:id
		             },
				 dataType:"json",
		         success:function(data){
		            if(data != null && data != ''){				        
			            var listStr ="<ul class='ultan'>"+
			                                "<li><h4>运&nbsp&nbsp&nbsp单&nbsp&nbsp&nbsp编&nbsp&nbsp&nbsp号："+data.waybailId+"</h4></li>"+
						        			"<li><h4>现&nbsp&nbsp&nbsp金&nbsp&nbsp&nbsp加&nbsp&nbsp&nbsp油："+data.cashRefueling+"</h4></li>"+
						        			"<li><h4>油&nbsp&nbsp&nbsp卡&nbsp&nbsp&nbsp加&nbsp&nbsp&nbsp油："+data.oilCardRefueling+"</h4></li>"+
						        			"<li><h4>罐&nbsp&nbsp&nbsp车&nbsp&nbsp&nbsp加&nbsp&nbsp&nbsp油："+data.refuelingTanker+"&nbsp&nbsp&nbspkg</h4></li>"+
						        			"<li><h4>过&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp路&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.toll+"</h4></li>"+
						        			"<li><h4>住&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp宿&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.quarterage+"</h4></li>"+
						        			"<li><h4>配&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp件&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.accessoriesFee+"<h4></li>"+
						        			"<li><h4>维&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp修&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.maintenance+"</h4></li>"+
						        			"<li><h4>保&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp养&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.maintenanceFee+"</h4></li>"+
						        			"<li><h4>协&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp调&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp费："+data.xieTiaoFei+"</h4></li>"+
						        			"<li><h4>其&nbsp&nbsp&nbsp它&nbsp&nbsp&nbsp费&nbsp&nbsp&nbsp用："+data.rest+"</h4></li>"+
						        			"<li><h4>出&nbsp&nbsp&nbsp车&nbsp&nbsp&nbsp领&nbsp&nbsp&nbsp款："+data.carDrawMoney+"</h4></li>"+
						        			"<li><h4>剩&nbsp&nbsp&nbsp余&nbsp&nbsp&nbsp费&nbsp&nbsp&nbsp用："+data.repayment+"</h4></li>"+
						        			"</ul>";
					     $("#listData").append(listStr);
				     }
		        }
		       });            
            $(".tan").removeClass("hide");
           }
        };
        /**
        * 添加报账的信息
        */   
        function addenterreimbursement(data){
           $.ajax({
                 	url:"${ctx}/tb_enter_reimbursement/tbEnterReimbursement/savedata",
		            type:"post",
		            data:data,
	           	    success:function(data){
	           	       $(".tan").addClass("hide");
	           	       alert("该运单审核通过");
                       window.location.href='${ctx}/tb_enter_reimbursement/tbEnterReimbursement/insertdata';                 
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
 						alert(XMLHttpRequest.status);
 						alert(XMLHttpRequest.readyState);
 						alert(textStatus);
   					}   	    
			});
       }; 
	</script>
	<style type="text/css">
		/*弹窗样式*/
		#maskY{
            background: #000;
            opacity: 0.75;
            /*IE兼容*/
            filter: alpha(opacity=75);
            height: 1000px;
            width: 100%;
            position: absolute;
            left: 0;
            top: 0;
            /*z-index: 1000;*/
          }
          #formDispach{
            position: fixed;
            left: 30%;
            top: 5%;
            /*z-index:1100;*/
          }
          .formCon{
            width: auto;
            height: auto;
            background: #FFF;
            position: relative;
          }
          #listData>ul{
			         list-style:none;
			         margin:0;
		  }
		  .tanUl>li{
			   margin-top: 10px;
			   padding-left:27%;
			   line-height:inherit;
			   text-align:left;
		  }
		  .ultan>li{
		      margin-top: 10px;
			  padding-left:20%;
			  line-height:inherit;
			  text-align:left;
		  }
		  .closeBtn{
		  margin-left: 89%;
		  }
	</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/tb_enter_reimbursement/tbEnterReimbursement/">搜索已报账</a></li>
		<shiro:hasPermission name="tb_enter_reimbursement:tbEnterReimbursement:edit"><li><a href="${ctx}/tb_enter_reimbursement/tbEnterReimbursement/form">回车报账添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="tbEnterReimbursement" action="${ctx}/tb_enter_reimbursement/tbEnterReimbursement/" method="post" class="breadcrumb form-search" style="height: auto; width: auto;">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form" style="height: auto; width: auto;">
			<li><label>id：</label>
				<form:input path="id" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			<li><label>订单id：</label>
				<form:input path="waybailId" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			<li><label>现金加油：</label>
				<form:input path="cashRefueling" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>油卡加油：</label>
				<form:input path="oilCardRefueling" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>罐车加油：</label>
				<form:input path="refuelingTanker" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>过路费：</label>
				<form:input path="toll" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>配件费：</label>
				<form:input path="accessoriesFee" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>维修费：</label>
				<form:input path="maintenance" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>保养费：</label>
				<form:input path="maintenanceFee" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>协调费：</label>
				<form:input path="xieTiaoFei" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>住宿费：</label>
				<form:input path="quarterage" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>其他：</label>
				<form:input path="rest" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>出车领款：</label>
				<form:input path="theCarDrawMoney" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>应返还费用：</label>
				<form:input path="repayment" htmlEscape="false" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<shiro:hasPermission name="tb_enter_reimbursement:tbEnterReimbursement:view">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>出车时间</th>
				<th>出车领款</th>
				<th>车牌号</th>
				<th>挂车号</th>
				<th>司机</th>
				<th>领款人</th>
				<th>运货/托运公司</th>
				<th>录入时间</th>
				<th>登记人</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${waybilllist}" var="list" >
			<tr>
				<td>
					<fmt:formatDate value="${list.outCarTime}" pattern="yyyy-MM-dd HH:mm:ss" />
				</a></td>
				<td>
					${list.tbOutCarRegister.money}
				</td>
				<td>
					${list.tbCarInfo.carCode}
				</td>
				<td>
					${list.tbCarInfo.carGCode}
				</td>
				<td>
				    <h4>${list.tbDriver.driverName}</h4>
				    <h4>${list.tbDriverTwo.driverName}</h4>									
				</td>
				<td>
					${list.tbOutCarRegister.tbDriverThree.driverName}
				</td>
				<td>
					${list.tbGoodsConsignmentCompany.shortName}
				</td>
				<td>
					<fmt:formatDate value="${list.createDate}" pattern="yyyy-MM-dd HH:mm:ss" />
				</td>
				<td>
					${list.updateBy.name}
				</td>
				<td>
				<input type="button" onclick="selectCostWaybillid('${list.id}','${list.state}','${list.tbOutCarRegister.money}',$(this))"  value="<c:if test="${list.state=='4' || list.state==4}">待报账</c:if><c:if test="${list.state=='5' || list.state==5}">审核中</c:if><c:if test="${list.state=='6' || list.state==6}">报账完毕</c:if>"/>
					<%-- <a href="${ctx}/tb_enter_reimbursement/tbEnterReimbursement/delete?id=${tbEnterReimbursement.id}" onclick="return confirmx('确认要删除该回车报账吗？', this.href)">删除</a> --%>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</shiro:hasPermission>
	<input id="" type="hidden">
	
	</input>
	
	<%--弹窗 --%>
		<div class="tan hide" id="maskY"></div>
		<section class="tan hide connectedSortable" id="formDispach" style="">
			<div class="formCon" style="">
			        <div class="input-group">
			          <div class="modal-dialog">
					  	 <div class="modal-content">
					          <div class="modal-header">
					            <button type="button" class="close" data-dismiss="modal" aria-label="Close"  >
					              <span aria-hidden="true">&times;</span></button>
					          </div>
					          <section class="invoice" id="invoice_context">
					              <div id="listData">
					              </div>
					          </section>          
					          <div class="modal-footer">
					            <button type="button" class="btn btn-default pull-right closeBtn" data-dismiss="modal" style="margin-left:0;">取消</button>
					          </div>
					        </div>
				        </div>
		  			</div>
			</div>
  		</section>
  	<%--弹窗 end--%>
</body>
<!-- jQuery 2.2.3 -->
<script src="${adminLET }/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="${adminLET }/https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.6 -->
<script src="${adminLET }/bootstrap/js/bootstrap.min.js"></script>
<!-- Morris.js charts -->
<script src="${adminLET }/https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="${adminLET }/plugins/morris/morris.min.js"></script>
<!-- Sparkline -->
<script src="${adminLET }/plugins/sparkline/jquery.sparkline.min.js"></script>
<!-- jvectormap -->
<script src="${adminLET }/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="${adminLET }/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- jQuery Knob Chart -->
<script src="${adminLET }/plugins/knob/jquery.knob.js"></script>
<!-- daterangepicker -->
<script src="${adminLET }/https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
<script src="${adminLET }/plugins/daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="${adminLET }/plugins/datepicker/bootstrap-datepicker.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="${adminLET }/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<script src="${adminLET }/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="${adminLET }/plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="${adminLET }/dist/js/app.min.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="${adminLET }/dist/js/pages/dashboard.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="${adminLET }/dist/js/demo.js"></script>

</html>